home *** CD-ROM | disk | FTP | other *** search
/ This Disc Bytes! / Power Computing - The Disc 2 - This Disc Bytes.ISO / mac / CodeWarrior 7 Lite for 68K / MacOS Support / Headers / Universal Headers / CursorDevices.h < prev    next >
Text File  |  1995-07-06  |  7KB  |  196 lines

  1. /*
  2.      File:        CursorDevices.h
  3.  
  4.      Contains:    Cursor Devices (mouse/trackball/etc) Interfaces.
  5.  
  6.      Version:    Technology:    System 7.5
  7.                  Package:    Universal Interfaces 2.1 in “MPW Latest” on ETO #18
  8.  
  9.      Copyright:    © 1984-1995 by Apple Computer, Inc.
  10.                  All rights reserved.
  11.  
  12.      Bugs?:        If you find a problem with this file, use the Apple Bug Reporter
  13.                  stack.  Include the file and version information (from above)
  14.                  in the problem description and send to:
  15.                      Internet:    apple.bugs@applelink.apple.com
  16.                      AppleLink:    APPLE.BUGS
  17.  
  18. */
  19.  
  20. #ifndef __CURSORDEVICES__
  21. #define __CURSORDEVICES__
  22.  
  23.  
  24. #ifndef __TYPES__
  25. #include <Types.h>
  26. #endif
  27. /*    #include <ConditionalMacros.h>                                */
  28.  
  29. #ifndef __MIXEDMODE__
  30. #include <MixedMode.h>
  31. #endif
  32.  
  33. #ifdef __cplusplus
  34. extern "C" {
  35. #endif
  36.  
  37. #if PRAGMA_ALIGN_SUPPORTED
  38. #pragma options align=mac68k
  39. #endif
  40.  
  41. #if PRAGMA_IMPORT_SUPPORTED
  42. #pragma import on
  43. #endif
  44.  
  45. /*
  46.                        * * *  W A R N I N G  * * * 
  47.  
  48.     On currently shipping PowerMacs, the CursorDevices manager is implemented
  49.     in 68K code and emulated.  Unfortunately, the MixedMode glue in InterfaceLib
  50.     is incorrect.  It and the 1.0 version of this file had incorrect parameter
  51.     lists for most functions.
  52.     
  53.     As a first step to avoid runtime errors, the functions in this file were 
  54.     renamed (e.g. from"CrsrDevButtons" to "CursorDeviceButtons").  This will result
  55.     in a link time error if a PowerPC application tries to call the functions.
  56.     When InterfaceLib is fixed, the new names will be exported and PowerPC
  57.     code will then be able to call them.
  58.     
  59. */
  60. typedef short ButtonOpcode;
  61.  
  62. /* ButtonOpcodes */
  63.  
  64. enum {
  65.     kButtonNoOp                    = 0,                            /* No action for this button */
  66.     kButtonSingleClick            = 1,                            /* Normal mouse button */
  67.     kButtonDoubleClick            = 2,                            /* Click-release-click when pressed */
  68.     kButtonClickLock            = 3,                            /* Click on press, release on next press */
  69.     kButtonCustom                = 6                                /* Custom behavior, data = CursorDeviceCustomButtonUPP */
  70. };
  71.  
  72. /* Device Classes */
  73. enum {
  74.     kDeviceClassAbsolute        = 0,                            /* a flat-response device */
  75.     kDeviceClassMouse            = 1,                            /* mechanical or optical mouse */
  76.     kDeviceClassTrackball        = 2,                            /* trackball */
  77.     kDeviceClass3D                = 6                                /* a 3D pointing device */
  78. };
  79.  
  80. /* Structures used in Cursor Device Manager calls */
  81. struct CursorData {
  82.     struct CursorData                *nextCursorData;            /* next in global list */
  83.     Ptr                                displayInfo;                /* unused (reserved for future) */
  84.     Fixed                            whereX;                        /* horizontal position */
  85.     Fixed                            whereY;                        /* vertical position */
  86.     Point                            where;                        /* the pixel position */
  87.     Boolean                            isAbs;                        /* has been stuffed with absolute coords */
  88.     UInt8                            buttonCount;                /* number of buttons currently pressed */
  89.     unsigned short                    screenRes;                    /* pixels per inch on the current display */
  90.     short                            privateFields[22];            /* fields use internally by CDM */
  91. };
  92. typedef struct CursorData CursorData, *CursorDataPtr;
  93.  
  94. struct CursorDevice {
  95.     struct CursorDevice                *nextCursorDevice;            /* pointer to next record in linked list */
  96.     CursorData                        *whichCursor;                /* pointer to data for target cursor */
  97.     long                            refCon;                        /* application-defined */
  98.     long                            unused;                        /* reserved for future */
  99.     OSType                            devID;                        /* device identifier (from ADB reg 1) */
  100.     Fixed                            resolution;                    /* units/inch (orig. from ADB reg 1) */
  101.     UInt8                            devClass;                    /* device class (from ADB reg 1) */
  102.     UInt8                            cntButtons;                    /* number of buttons (from ADB reg 1) */
  103.     UInt8                            filler1;                    /* reserved for future */
  104.     UInt8                            buttons;                    /* state of all buttons */
  105.     UInt8                            buttonOp[8];                /* action performed per button */
  106.     unsigned long                    buttonTicks[8];                /* ticks when button last went up (for debounce) */
  107.     long                            buttonData[8];                /* data for the button operation */
  108.     unsigned long                    doubleClickTime;            /* device-specific double click speed */
  109.     Fixed                            acceleration;                /* current acceleration */
  110.     short                            privateFields[15];            /* fields used internally to CDM */
  111. };
  112. typedef struct CursorDevice CursorDevice, *CursorDevicePtr;
  113.  
  114. /* for use with CursorDeviceButtonOp when opcode = kButtonCustom */
  115. /*
  116.         CursorDeviceCustomButtonProcPtr uses register based parameters on the 68k and cannot
  117.         be written in or called from a high-level language without the help of
  118.         mixed mode or assembly glue.
  119.  
  120.             typedef pascal void (*CursorDeviceCustomButtonProcPtr)(CursorDevicePtr ourDevice, short button);
  121.  
  122.         In:
  123.          => ourDevice       A2.L
  124.          => button          D3.W
  125. */
  126.  
  127. #if GENERATINGCFM
  128. typedef UniversalProcPtr CursorDeviceCustomButtonUPP;
  129. #else
  130. typedef Register68kProcPtr CursorDeviceCustomButtonUPP;
  131. #endif
  132.  
  133. enum {
  134.     uppCursorDeviceCustomButtonProcInfo = kRegisterBased
  135.          | REGISTER_ROUTINE_PARAMETER(1, kRegisterA2, SIZE_CODE(sizeof(CursorDevicePtr)))
  136.          | REGISTER_ROUTINE_PARAMETER(2, kRegisterD3, SIZE_CODE(sizeof(short)))
  137. };
  138.  
  139. #if GENERATINGCFM
  140. #define NewCursorDeviceCustomButtonProc(userRoutine)        \
  141.         (CursorDeviceCustomButtonUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppCursorDeviceCustomButtonProcInfo, GetCurrentArchitecture())
  142. #else
  143. #define NewCursorDeviceCustomButtonProc(userRoutine)        \
  144.         ((CursorDeviceCustomButtonUPP) (userRoutine))
  145. #endif
  146.  
  147. #if GENERATINGCFM
  148. #define CallCursorDeviceCustomButtonProc(userRoutine, ourDevice, button)        \
  149.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppCursorDeviceCustomButtonProcInfo, (ourDevice), (button))
  150. #else
  151. /* (*CursorDeviceCustomButtonProcPtr) cannot be called from a high-level language without the Mixed Mode Manager */
  152. #endif
  153.  
  154. extern pascal OSErr CursorDeviceMove(CursorDevicePtr ourDevice, long deltaX, long deltaY)
  155.  TWOWORDINLINE(0x7000, 0xAADB);
  156. extern pascal OSErr CursorDeviceMoveTo(CursorDevicePtr ourDevice, long absX, long absY)
  157.  TWOWORDINLINE(0x7001, 0xAADB);
  158. extern pascal OSErr CursorDeviceFlush(CursorDevicePtr ourDevice)
  159.  TWOWORDINLINE(0x7002, 0xAADB);
  160. extern pascal OSErr CursorDeviceButtons(CursorDevicePtr ourDevice, short buttons)
  161.  TWOWORDINLINE(0x7003, 0xAADB);
  162. extern pascal OSErr CursorDeviceButtonDown(CursorDevicePtr ourDevice)
  163.  TWOWORDINLINE(0x7004, 0xAADB);
  164. extern pascal OSErr CursorDeviceButtonUp(CursorDevicePtr ourDevice)
  165.  TWOWORDINLINE(0x7005, 0xAADB);
  166. extern pascal OSErr CursorDeviceButtonOp(CursorDevicePtr ourDevice, short buttonNumber, ButtonOpcode opcode, long data)
  167.  TWOWORDINLINE(0x7006, 0xAADB);
  168. extern pascal OSErr CursorDeviceSetButtons(CursorDevicePtr ourDevice, short numberOfButtons)
  169.  TWOWORDINLINE(0x7007, 0xAADB);
  170. extern pascal OSErr CursorDeviceSetAcceleration(CursorDevicePtr ourDevice, Fixed acceleration)
  171.  TWOWORDINLINE(0x7008, 0xAADB);
  172. extern pascal OSErr CursorDeviceDoubleTime(CursorDevicePtr ourDevice, long durationTicks)
  173.  TWOWORDINLINE(0x7009, 0xAADB);
  174. extern pascal OSErr CursorDeviceUnitsPerInch(CursorDevicePtr ourDevice, Fixed resolution)
  175.  TWOWORDINLINE(0x700A, 0xAADB);
  176. extern pascal OSErr CursorDeviceNextDevice(CursorDevicePtr *ourDevice)
  177.  TWOWORDINLINE(0x700B, 0xAADB);
  178. extern pascal OSErr CursorDeviceNewDevice(CursorDevicePtr *ourDevice)
  179.  TWOWORDINLINE(0x700C, 0xAADB);
  180. extern pascal OSErr CursorDeviceDisposeDevice(CursorDevicePtr ourDevice)
  181.  TWOWORDINLINE(0x700D, 0xAADB);
  182.  
  183. #if PRAGMA_IMPORT_SUPPORTED
  184. #pragma import off
  185. #endif
  186.  
  187. #if PRAGMA_ALIGN_SUPPORTED
  188. #pragma options align=reset
  189. #endif
  190.  
  191. #ifdef __cplusplus
  192. }
  193. #endif
  194.  
  195. #endif /* __CURSORDEVICES__ */
  196.